package jenum.com;

import page.Book2;

/**
 * Created by as on 2016/11/17.
 */
public class CustomEx {
    public static void main(String[] args)
    {
        Books books = new Books();
        try{
            books.setPrice(99.00);
        }
        catch (BookException e){
            System.out.println(e);
        }
    }
}

class BookException extends RuntimeException{
    public BookException(String msg)
    {
        super(msg);
    }
}

class Books{
    private double price = 100.0;
    public void setPrice(double price) throws BookException{
        if (price<100.0 || price>1000.0){
            throw new BookException("定价设定错误，不能为：" + price);
        }else{
            this.price = price;
        }
    }

    public double getPrice(){
        return price;
    }
}


